package example.tomcat;

import example.tomcat.web.IndexServlet;
import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.startup.Tomcat;

public class Tomcat_Test {

    public static void main(String[] args) throws LifecycleException {
        Tomcat tomcat = new Tomcat();
        tomcat.setPort(9070);
        tomcat.start();
        IndexServlet indexServlet = new IndexServlet();
        // 项目访问路径
        Context context = tomcat.addWebapp("/boot", "E:\\gq\\");
        // 当前项目的访问地址
        tomcat.addServlet("/boot", "index", indexServlet);
        context.addServletMappingDecoded("/index.do", "index");
        tomcat.getServer().await();
    }
}
